function getFlashMovie(movieName){
    var isIE = navigator.appName.indexOf("Microsoft") != -1;
    return (isIE) ? window[movieName] : document[movieName];
}

function sendToActionScript(cas, name, img_id, user_id){
    getFlashMovie("myFlashContent").sendTextToFlash(cas, name, img_id, user_id);
}

function sendToBoard(cas, txt, id){
    getFlashMovie("myFlashBoard").sendTextToBoard(cas, txt, id);
}

function editImg(cas, img_id, name, status, user_id){
    if (cas==0) {
        getFlashMovie("myFlashBoard").sendTextToBoard(2, img_id + "," + name + "," + status + "," + user_id);
        _changeDroit(img_id);
    } else if (cas==1){
    	getFlashMovie("myFlashBoard").sendTextToBoard(2, img_id + "," + name + "," + status + "," + user_id);
    }
}

function addNewImage(img_id, name, status, user_id){
    if (img_id) {
        V2JS_Message(img_id + " " + name + " " + user_id);
        sendToActionScript(2, name, img_id, _global_id_user);
    }
}

function changeTheWorld(cas, img_id, name, status, user_id){
    if (name) {
        V2JS_Message("lola");
    }
    if (cas == 1) {
        V2JS_Message("placement info: " + img_id + " " + name);
        JS2V_uploadSucceed(name, img_id);
    }
}

//flash to js
function makeMove(cas, direction, id){
	
	
    if (cas == 1) {
		
        V2JS_Message("cas:" + cas + " dir:" + direction + " user:" + id);
		 var cmd = "SendMessage 'FrameMouseCam' '" + direction + "'";
        document.Virtools.DoCommand(cmd);
    }
    else 
        if (cas == 2) {
            V2JS_Message("cas:" + cas + " angle:" + direction + " img:" + id);
			var cmd = "SetAttribute '3dFrame_attribute' 'angle' '" + direction + "'";
	        document.Virtools.DoCommand(cmd);
			cmd = "SendMessage 'Level' 'angle'";
	        document.Virtools.DoCommand(cmd);
        }

}

// Deplacement de l'image après Upload
function moveImg(cas, move, id){  
 
 if (cas == 1) {
	var cmd = "SendMessage 'Level' '" + move + "'";
	V2JS_Message(cmd);
	document.Virtools.DoCommand(cmd);
  } 
	else if (cas== 2) {
	var cmd = "SendMessage 'Level' '" + move + "'";
//	V2JS_Message(cmd);
//	document.Virtools.DoCommand(cmd);
  }
}


//js to flash
function showMove(cas, direction, id){
    if (cas == 1) {
       
        sendToBoard(3, direction, id);
        
        V2JS_Message("cas:" + cas + " dir:" + direction + " user:" + id);
       
        
        var cmd = "SendMessage 'FrameMouseCam' '" + direction + "'";
        document.Virtools.DoCommand(cmd);
        
    }
    else 
        if (cas == 2) {
        
            sendToBoard(4, direction, id);
            
            V2JS_Message("cas:" + cas + " angle:" + direction + " img:" + id);
            
            
            
        }
}
